package org.xiaoxin.onecoupon.engine.config;

import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 布隆过滤器配置类
 * @author xiaoxin
 * 2025/4/24
 */
@Configuration
public class RBloomFilterConfiguration {
   /**
    * 优惠券查询缓存穿透布隆过滤器
    */
   @Bean
   public RBloomFilter<String> couponTemplateQueryBloomFilter(RedissonClient redissonClient) {
      RBloomFilter<String> bloomFilter = redissonClient.getBloomFilter("couponTemplateQueryBloomFilter");
      bloomFilter.tryInit(640L, 0.001);
      return bloomFilter;
   }
}
